/*
 * addServicestoOrder.java
 *
 * Created on March 25, 2006, 12:16 AM
 */

package phs_project;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

/**
 *
 * @author  nhoc
 */
public class addServicestoOrder extends javax.swing.JDialog {
    
    /** Creates new form addServicestoOrder */
    public addServicestoOrder(JFrame parent,boolean check) {
        super(parent,check);
        initComponents();
        
        if (hotelForm.ODID==null)
        {
            JOptionPane.showMessageDialog(this,"Bạn không thể gọi trực tiếp form này vì cần có tham số");
        }
        else 
        {    
            //SQLRUN("sumtotal "+hotelForm.ODID+"");
            addDataToTextField("select * from orderofcus where orderid='"+hotelForm.ODID+"'","orderDate",Ngaydat);
            addDataToTextField("select * from orderofcus where orderid='"+hotelForm.ODID+"'","cusname",Nguoidat);
            serviceTypeShow();
            roomInorderShow();    
            orderId.setText(hotelForm.ODID);
            ServiceInorderShow(orderId.getText());
        }
       
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        orderId = new javax.swing.JTextField();
        Ngaydat = new javax.swing.JTextField();
        Nguoidat = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        serviceType = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        RoomInorder = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        SeviceName = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        giamgia = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        phuphi = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        GiaDV = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        scrool = new javax.swing.JScrollPane();
        ServiceInorder = new javax.swing.JTable();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Th\u00eam d\u1ecbch v\u1ee5 v\u00e0o \u0111\u01a1n h\u00e0ng");
        setAlwaysOnTop(true);
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("\u0110\u01a1n \u0111\u01a1n h\u00e0ng"));
        jLabel1.setText("M\u00e3 \u0111\u01a1n h\u00e0ng");

        jLabel2.setText("Ng\u00e0y \u0111\u1eb7t");

        jLabel3.setText("Ng\u01b0\u1eddi \u0111\u1eb7t");

        orderId.setEditable(false);

        Ngaydat.setEditable(false);
        Ngaydat.setText("?");

        Nguoidat.setEditable(false);
        Nguoidat.setText("?");

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(orderId)
                    .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .add(17, 17, 17)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel3)
                    .add(Nguoidat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 183, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel2)
                    .add(Ngaydat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 206, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(36, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(jLabel3)
                    .add(jLabel2))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(orderId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(Nguoidat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(Ngaydat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh s\u00e1ch d\u1ecbc v\u1ee5 s\u1ebd th\u00eam"));
        serviceType.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                serviceTypeItemStateChanged(evt);
            }
        });

        jLabel4.setText("Ch\u1ecdn lo\u1ea1i d\u1ecbc v\u1ee5");

        jLabel6.setText("Cho ");

        SeviceName.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        SeviceName.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SeviceNameMouseClicked(evt);
            }
        });

        jScrollPane1.setViewportView(SeviceName);

        jButton1.setText("Th\u00eam v\u00e0o");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        giamgia.setText("0");

        jLabel7.setText("Gi\u1ea3m gi\u00e1");

        jLabel8.setText("Ph\u00ed ph\u00e1t sinh");

        phuphi.setText("0");

        jLabel9.setText("Gi\u00e1 DV");

        GiaDV.setText("0");

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel4)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(serviceType, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 130, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel6)
                        .add(23, 23, 23)
                        .add(RoomInorder, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 106, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel9)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(GiaDV, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel7)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(giamgia, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel8)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(phuphi, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 68, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE)
            .add(jPanel2Layout.createSequentialGroup()
                .add(443, 443, 443)
                .add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(serviceType, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 128, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(RoomInorder, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 18, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel9)
                        .add(GiaDV, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel7))
                    .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel8)
                        .add(phuphi, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(giamgia, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton1)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh s\u00e1ch d\u1ecbc v\u1ee5 hi\u1ec7n c\u00f3 c\u1ee7a \u0111\u01a1n h\u00e0ng"));
        ServiceInorder.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        ServiceInorder.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ServiceInorderMouseClicked(evt);
            }
        });

        scrool.setViewportView(ServiceInorder);

        jButton3.setText("B\u1ecf ra");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(scrool, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE)
            .add(jPanel3Layout.createSequentialGroup()
                .add(443, 443, 443)
                .add(jButton3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .add(jButton3)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(scrool, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 105, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jButton4.setText("Quay l\u1ea1i");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(454, Short.MAX_VALUE)
                        .add(jButton4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton4))
        );
        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:
        this.dispose();
        hotelForm.ODID = null;
    }//GEN-LAST:event_jButton4ActionPerformed

  
    private void ServiceInorderMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ServiceInorderMouseClicked
// TODO add your handling code here:
        int  row;
        row = ServiceInorder.getSelectedRow();
        svInOdId=ServiceInorder.getValueAt(row,0).toString();
        //System.out.println(SeviceName.getValueAt(row,0));
       System.out.println(svInOdId);
    }//GEN-LAST:event_ServiceInorderMouseClicked

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
        RemoveServices();
    }//GEN-LAST:event_jButton3ActionPerformed

     private void RemoveServices(){
        if(svInOdId==null){
            JOptionPane.showMessageDialog(this,"Bạn phải chọn một dịc vụ để bỏ ra");
        }
        else{
            SQLRUN ("delete servicesDetail where idservices_detail ='"+svInOdId+"'");
            ServiceInorderShow(oderName);
            svId=null;
            svInOdId=null;
        
        }
        }
    private void SeviceNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SeviceNameMouseClicked
// TODO add your handling code here:
        int  row;
        row = SeviceName.getSelectedRow();
        svId=SeviceName.getValueAt(row,0).toString();
        svCost =SeviceName.getValueAt(row,2).toString();
        GiaDV.setText(svCost);
        //System.out.println(SeviceName.getValueAt(row,0));
        //System.out.println(svId);
        
        
        
    }//GEN-LAST:event_SeviceNameMouseClicked

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
       AddServices();
        
    }//GEN-LAST:event_jButton1ActionPerformed
 
     private void AddServices()
        {
//Goi cau truy van
        if (svId==null){
            JOptionPane.showMessageDialog(this,"Bạn phải chọn một dịc vụ để thêm vào!");
        }
        else
        {
        String SqlInsertService;
        String sqlupdate;
        String RoomNum;
        RoomNum=selectDateToString("Select roomid from rooms where roomnumb= '"+RoomInorder.getSelectedItem().toString()+"'","roomid");
        //RoomNum =RoomInorder.getSelectedItem().toString();
        //RoomNum
           int g= Integer.parseInt( GiaDV.getText()) ; 
           //Integer.parseInt()
           int gg =Integer.parseInt(giamgia.getText()); 
           int pp=Integer.parseInt(phuphi.getText());
        int Tongso  = g+gg+pp ;   
        SqlInsertService = "insert into servicesdetail (orderid,servicesid,roomnum,sv_addition,sv_discount,sv_total) values (" ;
        SqlInsertService=SqlInsertService+"'"+orderId.getText()+"','"+svId+"','"+RoomNum+"','"
                +phuphi.getText()+"','"+giamgia.getText()+"','"+Tongso+"')";
        
        SQLRUN (SqlInsertService);
        //SQLRUN("sumtotal "+hotelForm.ODID+"");
        System.out.println(SqlInsertService);
       // serviceTypeShow();
        serviceTBNameShow(Type);
        ServiceInorderShow(oderName); // load lai bang dich vu da co cua orders
        svId=null;
        svInOdId=null;
        }
        }
     
    private void serviceTypeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_serviceTypeItemStateChanged
// TODO add your handling code here:
         serviceTBNameShow(Type);
         svId=null;
         svInOdId=null;
        
    }//GEN-LAST:event_serviceTypeItemStateChanged
    
    /**
     * @param args the command line arguments
     */
    private void serviceTypeShow(){
        String sqlshow = "select TypeName from servicestype";
        serviceType.addItem("Tất cả");
        new sqlDatabase().addDataCombobox(sqlshow,serviceType);
    }
    private void serviceTBNameShow(String loaiDV){
     if (serviceType.getSelectedItem().toString()=="Tất cả") {
            loaiDV="all";
            String sqlshowSV=  "select * from servicejointype where [Loại] <>'"+loaiDV+"'";
            new sqlDatabase().addDataTable(sqlshowSV,SeviceName);
            new publicClass().hiddencol(SeviceName,0);
        }
        else {
            loaiDV =serviceType.getSelectedItem().toString();
            String sqlshowSV=  "select * from servicejointype where [Loại] =N'"+loaiDV+"'";
            new sqlDatabase().addDataTable(sqlshowSV,SeviceName);}
            new publicClass().hiddencol(SeviceName,0);
    }
    
    private void ServiceInorderShow(String OdId){
        OdId=orderId.getText();
        String sqlshowSV=  "select [MãDV],[Tên dịch vụ],[Giá tiền],[Giảm giá], [Phụ phí], [Tổng tiền], [Loại],[Của phòng] from costofservices where [Mã] ='"+OdId+"'";
        new sqlDatabase().addDataTable(sqlshowSV,ServiceInorder);
        new publicClass().hiddencol(ServiceInorder,0);
    }
    private void roomInorderShow()
    {
        String sqlshow = "select [Tên phòng] from roomInorder  where roomStatusId=5 and orderId='"+hotelForm.ODID+"'";
        RoomInorder.addItem("Cả đoàn");
        new sqlDatabase().addDataCombobox(sqlshow,RoomInorder);
        //System.out.println(sqlshow);
    }
     private void SQLRUN (String SQLTEXT)
     {
       try{
            Connection conn = new connectDatabase().getConnection();
            Statement stm = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
            stm.execute(SQLTEXT);
            conn.close();
            stm.close();
            System.out.println(SQLTEXT);
        }
        catch(Exception e){
            e.printStackTrace();
        }
        //System.out.println(SqlInsertService);
     }
      public String selectDateToString(String sql,String rsName) // dua du lieu tu trong cau truy van ra bien string
    {
        String returnvl ="" ;
        //Connection con =null;
        if(con == null){
            con = new connectDatabase().getConnection();
        }
        try{
            Statement sttm = con.createStatement();
            ResultSet rs = sttm.executeQuery(sql);
            while(rs.next()){
                System.err.println(rs.getString(rsName));
                returnvl = rs.getString(rsName);
            }
            sttm.close();
            rs.close();
        } catch(Exception e){
            e.printStackTrace();
        }
        return returnvl;
    }
      public void addDataToTextField(String sql,String rsName,JTextField TexFiedName) // dua du lieu tu trong cau truy van vao bang
    {
        //Connection con =null;
        if(con == null){
            con = new connectDatabase().getConnection();
        }
        try{
            Statement sttm = con.createStatement();
            ResultSet rs = sttm.executeQuery(sql);
            while(rs.next()){
                TexFiedName.setText(rs.getString(rsName));
            }
            sttm.close();
            rs.close();
        } catch(Exception e){
            e.printStackTrace();
        }
    }
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new addServicestoOrder(new JFrame(),true).setVisible(true);
            }
        });
    }
    //private Connection conn;
    private Connection con ;
    private String oderName;
    private String Type;
    private String svId;
    private String svInOdId;
    private String svCost;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField GiaDV;
    private javax.swing.JTextField Ngaydat;
    private javax.swing.JTextField Nguoidat;
    private javax.swing.JComboBox RoomInorder;
    private javax.swing.JTable ServiceInorder;
    private javax.swing.JTable SeviceName;
    private javax.swing.JTextField giamgia;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField orderId;
    private javax.swing.JTextField phuphi;
    private javax.swing.JScrollPane scrool;
    private javax.swing.JComboBox serviceType;
    // End of variables declaration//GEN-END:variables
    
}
